// 以图搜图
    $('body').on('click', '.select-pic_search', function (ev) {
        $.getJSON('/shitu/uploadAuth', function (data) {
            $('input[name="policy"]').val(data['policy']);
            $('input[name="authorization"]').val(data['authorization']);
        });
        $('#file').click();
        $('body').on('change', '#file', function (){
            var val = $(this).val();
            if (!val) return;
            $('.put-img-hint').show();
            $('.uploading').show();
            $('.error-hint').hide();
            $('#photo_search').submit();
        });
        Mark = null;
        if(window.ActiveXObject || 'ActiveXObject' in window) {
            setInterval(function (){
                var val = $('#file').val();
                if (val != '' && Mark == void 0) {
                    $('.put-img-hint').show();
                    $('.uploading').show();
                    $('.error-hint').hide();
                    Mark = 1;
                    $('#photo_search').submit();
                }
            },500);
        }
        var oEvent = ev || event;
        if(oEvent && oEvent.stopPropagation) { //非IE
            oEvent.stopPropagation();
        } else { //IE
            window.event.cancelBubble = true;
        }
    });
    $('body').on('mouseover', '.drop-box_item', function(event) {
        event.preventDefault();
        window.dropTimer && clearTimeout(window.dropTimer);
        $('.drop-box_content').hide();
        $(this).find('.drop-box_content').show();
    });
    $('body').on('mouseout', '.drop-box_item', function(event) {
        event.preventDefault();
        window.dropTimer = setTimeout(function () {
            $('.drop-box_content').hide();
        }, 200);
    });
var oGlobalType = $('.header-search .header-search_tag .drop-box_top').attr('data-type');
$.each($('.header-search .header-search_tag .drop-box_content li'), function(index, val) {
    if($(val).attr('data-type') == oGlobalType) {
        $(val).hide();
    }
});
if (CONFIG['uid'] > 0){
   $.ajax({
       type:'post',
       url:'http://ajax.699pic.com/?c=AjaxPublic&a=getUnreadNum',
       jsonp: "callback",
       dataType: "jsonp",
       success:function(d){
           if (d.status == true && d.num > 0) {
               $(".news_num").show();
           } else {
               $(".news_num").hide();
           }
       }
   });
}
$(".news_hover").off("mouseenter");
$(".news_hover").off("mouseleave");
$(".news_hover").off("mouseover");
$(".news_hover").off("mouseout");
var is_ajax  , news_show, news_hide= '';
$(".InMail-block").on("mouseenter.sp_base", function(){
    clearTimeout(news_hide);
    news_show = setTimeout(function(){
        $(".news_wrapper").attr("data", "show");
        var show = $(".news_wrapper").attr("data");
        if (show == 'show') {
            $(".news_wrapper").show();
            if (is_ajax) return;
            $.ajax({
                type:'post',
                url:'http://699pic.com/dongtai/getAllInfo',
                success:function(d){
                    if (d.status == true) {
                        is_ajax = true;
                        $(".null_content").hide();
                        $(".news_wrapper").html(d.html);
                    }
                }
            })
        }
    }, 500);
}).on("mouseleave", function(){
    clearTimeout(news_show);
    news_hide = setTimeout(function(){
        $(".news_wrapper").attr("data", '');
        var hide = $(".news_wrapper").attr("data");
        if (hide == '') {
            $(".news_wrapper").hide();
        }
    }, 500);
});
        // GLOBAL Event Emit
var customEvent = (function () {
    var events = {}
    function on(evt, handler) {
        events[evt] = events[evt] || []
        events[evt].push({
            handler: handler
        })
    }
    function trigger(evt, args) {
        if(!events[evt]) {
            return
        }
        for (var i = 0; i < events[evt].length; i++) {
            events[evt][i].handler(args)
        }
    }
    return {
        on: on,
        trigger: trigger
    }
})();
// 自定义 LocalStorage 处理（有过期时间功能）
function customLocalStorage() {
    this.set = function (key,value) {
        var curTime = new Date().getTime();
        localStorage.setItem(key,JSON.stringify({data:value,time:curTime}));
    }
    this.get = function (key,exp) {
        var data = localStorage.getItem(key);
        if (data) {
            var dataObj = JSON.parse(data);
            if(!exp) {
                var dataObjDatatoJson = dataObj.data
                return dataObjDatatoJson;
            }
            if (new Date().getTime() - dataObj.time>exp) {
                console.log('信息已过期');
                customEvent.trigger('local_remove', key);
            }else{
                var dataObjDatatoJson = dataObj.data
                return dataObjDatatoJson;
            }
        } else {
            customEvent.trigger('local_remove', key);
        }
    },
    this.remove = function (key) {
        localStorage.removeItem(key);
    }
};
// 动态处理 input 的 placeholder
function handleInputPlaceHolder(oType) {
    var oPlaceHolder = '';
    if(oType) {
        switch (oType) {
            case 'all':oPlaceHolder = '大家正在搜：GIF动图素材';break;
            case 'photo':oPlaceHolder = '从优质照片中找到你的灵感';break;
            case 'chahua':oPlaceHolder = '有些画，我们只动了手，而你却动了心';break;
            case 'originality':oPlaceHolder = '表达创意的方式不止一种';break;
            case 'muban':oPlaceHolder = '设计探索未来';break;
            case 'video':oPlaceHolder = '优质视频音效，极致通用';break;
            case 'PPT':oPlaceHolder = '高效办公不加班';break;
            case 'peitu':oPlaceHolder = '正版精品手机配图';break;
            case 'yuansu':oPlaceHolder = '正版精品免抠元素';break;
            case 'gif':oPlaceHolder = '让图片动起来';break;
            case 'music':oPlaceHolder = '输入关键词，点击搜索按钮找音乐';break;
            default: oPlaceHolder = '输入关键字搜索，少于4字最佳';break;
        }
    } else {
        oPlaceHolder = '输入关键字搜索，少于4字最佳';
    }
    $('#search-input').attr('placeholder', oPlaceHolder);
}
handleInputPlaceHolder($('#selfSearchMode').val());
// addEventListen 兼容写法
var addEvent = function (element, type, handler) {
    if(element.addEventListener) {
        addEvent = function (element, type, handler) {
            element.addEventListener(type, handler, false);
        };
    } else if(element.attachEvent) {
        addEvent = function (element, type, handler) {
            element.attachEvent('on' + type, handler);
        };
    } else {
        addEvent = function (element, type, handler) {
            element['on' + type] = handler;
        };
    }
    addEvent(element, type, handler);
};
// isArray POLYFILL
if (!Array.isArray) {
  Array.isArray = function(arg) {
    return Object.prototype.toString.call(arg) === '[object Array]';
  };
}
function stopDefault(e) {
    //阻止默认浏览器动作(W3C)
    if (e && e.preventDefault) {
        //火狐的 事件是传进来的e
        e.preventDefault();
    }
        //IE中阻止函数器默认动作的方式
    else {
        //ie 用的是默认的event
        event.returnValue = false;
    }
}
// -------GLOBAL Event Emit End-------

// Event Listener
$('body').on('click', '.header-search_tag .drop-box_content li', function(event) {
    event.preventDefault();
    $('.header-search_tag .drop-box_top').attr('data-type', ($(this).attr('data-type')));
    $(this).parents('.drop-box_content').hide();
    $(this).hide().siblings().show();
    $(this).parents('.drop-box_item').find('.drop-box_top span').text($(this).find('span').text())
    $(this).parents('.drop-box_item').find('.drop-box_top').attr('data-type', $(this).attr('data-type'));
    handleInputPlaceHolder($(this).attr('data-type'));
});
$('body').on('click', '.result-search_release span, .result-bot_tip span', function(event) {
    event.preventDefault();
    var oValue = $(this).text();
    handleSearch(oValue);
});
var throttleBool = null;
var isSearchPage = $('#isSearchPage').val();
var needScrollHeight = $('.sea-nav-m').outerHeight()+40+174;
$(window).resize(function(event) {
    needScrollHeight = $('.sea-nav-m').outerHeight()+40+174;
});
$(window).scroll(function(event) {
    throttleBool && clearTimeout(throttleBool);
    throttleBool = setTimeout(function () {
        var scrollTop = $(this).scrollTop();
        if(scrollTop > needScrollHeight && isSearchPage == 2) {
            $('#sp-header').css('position', 'fixed');
            $('#sp-header').addClass("header_move");
        } else {
            $('#sp-header').css('position', 'absolute');
            $('#sp-header').removeClass("header_move");
        }
    }, 50)
});

$('.seek-select').hover(function(){
    $('.select-list').show()
},function(){
    $('.select-list').hide()
});
$('body').on('mouseover', '.search-suggest_item', function(event) {
    $('.search-suggest_item').removeClass('active');
    $(this).addClass('active');
});
$('body').on('click', '.search-suggest_item', function(event) {
    event.preventDefault();
    event.stopPropagation();
    var oValue = $(this).find('.search-suggest_name').text();
    handleSearch(oValue);
});

var timerInputKeyup = '';
$('body').on('keyup', '#search-input', function(event) {
    event.preventDefault();
    var oValue = $.trim($(this).val());
    var keyCode = event.keyCode;
    var oActiveIndexHolder = $(".search-suggest_item.active ").index();
    var oActiveIndexHot = $(".search-hotwords_item.active ").index();
    if($('.search-release').css("display") == "block") {
        if(keyCode == 38) {
            if(oActiveIndexHolder <= 0) {
                oActiveIndexHolder = $(".search-suggest_item").length;
            }
            oActiveIndexHolder --;
            $(this).val($(".search-suggest_item:eq("+oActiveIndexHolder+") .search-suggest_name").text());
            $(".search-suggest_item").removeClass('active');
            $(".search-suggest_item:eq("+oActiveIndexHolder+")").addClass('active');
            stopDefault(event);
            return
        } else if (keyCode == 40) {
            if(oActiveIndexHolder == $(".search-suggest_item").length -1) {
                oActiveIndexHolder = -1;
            }
            oActiveIndexHolder ++;
            $(this).val($(".search-suggest_item:eq("+oActiveIndexHolder+") .search-suggest_name").text());
            $(".search-suggest_item").removeClass('active');
            $(".search-suggest_item:eq("+oActiveIndexHolder+")").addClass('active');
            stopDefault(event);
            return
        }
    }

    if($('.search-rec').css("display") == "block") {
        // keyCode 38 上 40 下
        if(keyCode == 38) {
            if(oActiveIndexHot <= 0) {
                oActiveIndexHot = $(".search-hotwords_item").length;
            }
            oActiveIndexHot --;
            $(this).val($(".search-hotwords_item:eq("+oActiveIndexHot+") .search-hotwords_name").text());
            $(".search-hotwords_item").removeClass('active');
            $(".search-hotwords_item:eq("+oActiveIndexHot+")").addClass('active');
            stopDefault(event);
            return
        } else if (keyCode == 40) {
            if(oActiveIndexHot == $(".search-hotwords_item").length -1) {
                oActiveIndexHot = -1;
            }
            oActiveIndexHot ++;
            $(this).val($(".search-hotwords_item:eq("+oActiveIndexHot+") .search-hotwords_name").text());
            $(".search-hotwords_item").removeClass('active');
            $(".search-hotwords_item:eq("+oActiveIndexHot+")").addClass('active');
            stopDefault(event);
            return
        }
    }
    timerInputKeyup && clearTimeout(timerInputKeyup);
    timerInputKeyup = setTimeout(function () {
        if(keyCode == 13) {
            var oBaiduKey = CONFIG['baiduCusKey']|| 'index-search';
            var oBaiduValue = CONFIG['baiduCusValue']|| '首页搜索';
            var oWebKey = CONFIG['webCusKey'] || 'index-search';
            var oWebValue = CONFIG['webCusValue'] || 'click';
            CONFIG['webCusKey'] && successDownTjV3(oWebKey, oWebValue);
            handleSearch(oValue);
            _hmt.push(['_trackEvent', oBaiduKey, 'submit', oBaiduValue]);
        }
        if(!oValue) {
            $('.search-release').hide();
            $('.search-rec').show();
            handleNoHolderWords();
            return
        }
        $('.search-rec').hide();
        ajaxSearchHolderWords(oValue, function (response) {
            renderSearchHolderWords(response);
        })
    }, 500)
});
$('body').on('click', '.header-search_btn', function(event) {
    event.preventDefault();
    var oValue = $.trim($('#search-input').val());
    var oBaiduKey = CONFIG['baiduCusKey']|| 'index-search';
    var oBaiduValue = CONFIG['baiduCusValue']|| '首页搜索';
    var oWebKey = CONFIG['webCusKey'] || 'index-search';
    var oWebValue = CONFIG['webCusValue'] || 'click';
    CONFIG['webCusKey'] && successDownTjV3(oWebKey, oWebValue);
    handleSearch(oValue);
    _hmt.push(['_trackEvent', oBaiduKey, 'submit', oBaiduValue]);
});
$('body').on('focus', '#search-input', function(event) {
    event.preventDefault();
    // if($('#sp-header').css('position') == 'fixed') {
    //     $('.result-toast').hide();
    // }
    if($.trim($(this).val()) == '') {
        $('.search-rec').show();
        handleNoHolderWords();
    } else {
        $('.search-rec').hide();
        ajaxSearchHolderWords($.trim($(this).val()), function (response) {
            renderSearchHolderWords(response);
        })
    }
});
$('body').on('blur', '#search-input', function(event) {
    event.preventDefault();
    // if($('#sp-header').css('position') == 'fixed') {
    //     $('.result-toast').show();
    // }
    setTimeout(function () {
        $('.search-rec').hide();
        $('.search-release').hide();
    }, 180)
});
$('body').on('click', '.search-history span', function(event) {
    event.preventDefault();
    handleSearch($(this).text());
});

// -------Event Listener End-------
// AJAX Fn
/* 获取搜索词 推荐词
 * @word: 实时输入的字词
 * @callback: 获得数据后的回调
 */
function ajaxSearchHolderWords(word, callback) {
    var oType = $('.header-search_tag .drop-box_top').attr('data-type');
    $.ajax({
        url: devAjaxPrefix + '/word_completion.php',
        type: 'get',
        dataType: 'json',
        data: {
            keyword: word,
            type: oType
        },
        success: function (data) {
            if(data.status == 1) {
                callback && callback(data.data);
            }
        },
        error: function (error) {
            console.log(error);
        }
    })
}
/* 请求热门搜索词
 * @type: 分类 e.g: all / photo / chahua / originality / muban / video / PPT / peitu / yuansu
 * @callback: 获得数据后的回调
 */
function ajaxSearchHotWords(type,callback) {
    $.ajax({
        url: devAjaxPrefix + '/hot_search_word.php?type='+type,
        type: 'get',
        dataType: 'json',
        success: function (data) {
            if(data.status == 1) {
                var oData = JSON.parse(data.data);
                if (oData.length>0) {
                    callback && callback(oData);
                } else {
                    callback && callback(null);
                }
            }
        },
        error: function (error) {
            console.log(error);
        }
    });
}
// -------AJAX Fn End-------

// Render Fn
function renderSearchHolderWords(oData) {
    var oDom = '';
    if(oData) {
        if (Array.isArray(oData) && oData.length === 0) {
           $('.search-release').hide();
           return
        }
        for (var i in oData) {
            oDom += '<a class="search-suggest_item"><span class="search-suggest_name fl">'+i+'</span><span class="search-suggest_num fr">'+oData[i]+'结果</span></a>'
        }
        $('.search-suggest').html(oDom);
        $('.search-release').show();
    }
}
function renderSearchHotWords(data) {
    var oHotWords = '';
    if(data) {
        $.each(data, function(index, val) {
            var isFirstThree = '';
            if (index < 3) {
                isFirstThree = 'special ';
            }
            oHotWords += '<a href="'+val.url+'" class="search-hotwords_item"><span class="'+isFirstThree+'rank-index">'+val.index+'</span><span class="search-hotwords_name">'+val.kw+'</span><span class="search-hotwords_num fr">'+val.result+'结果</span></a>'
        });
    } else {
        $('.search-rec').css({
            'border-radius': '10px',
            'overflow': 'hidden'
        });
        $('.search-hotwords').css('padding', '0');
    }
    $('.search-hotwords').html(oHotWords);
}
function renderRecentSearch() {
    var lastRecentSearch = window.localStorage.getItem('recent_search_data');
    if(lastRecentSearch) {
        $('.search-history').show();
        lastRecentSearch = JSON.parse(lastRecentSearch);
        var oDom = '';
        if (lastRecentSearch && lastRecentSearch.length>0) {
            $.each(lastRecentSearch, function(index, val) {
                oDom += '<span>'+val+'</span>';
            });
            $('.search-history .search-recent_local').html(oDom);
        }
    } else {
        $('.search-history').hide();
    }
}
renderRecentSearch();
// -------Render Fn End-------


// Page content js
var customLocalStorage = new customLocalStorage();
// var devAjaxPrefix = 'http://cors.awebman.com/http://699pic.com';
var devAjaxPrefix = "";
function handleNoHolderWords() {
    if (CONFIG.is_index > 0) {
        var oType = $('.header-search_tag .drop-box_top').attr('data-type');
        var localKey = 'search_hot_words_'+oType;
        var response = customLocalStorage.get(localKey, 2*3600*1000);
        if(response) {
            renderSearchHotWords(JSON.parse(response));
        } else {
            renderSearchHotWords(null);
        }
    }
}
customEvent.on('local_remove', function (key) {
    // 删除对应的 localStorage item值
    customLocalStorage.remove(key);
    // ajaxNewData
    var oType = key.split('search_hot_words_')[1]
    ajaxSearchHotWords(oType, function (data) {
        if(data == null) {
            $('.search-hotwords').html(oHotWords);
            customLocalStorage.set(key, null);
            return
        }
        renderSearchHotWords(data);
        // then 重新设置 key值
        customLocalStorage.set(key, JSON.stringify(data));
    })
});
function handleSearch(word) {
    var searchMode =  $('.header-search_tag .drop-box_top').attr('data-type');
    word = $.trim(word).toLowerCase();
    var isSpecialWords = false;

    var lastRecentSearch = window.localStorage.getItem('recent_search_data');
    if(lastRecentSearch) {
        lastRecentSearch = JSON.parse(lastRecentSearch);
        var tempLength = 0;
        $.each(lastRecentSearch, function(index, val) {
            if(val !== word) {
                tempLength += 1;
            }
        });
        if(tempLength == lastRecentSearch.length) {
            lastRecentSearch.unshift(word);
        }
    } else {
        var tempArr = [];
        tempArr.push(word)
        lastRecentSearch = tempArr;
    }
    window.localStorage.setItem('recent_search_data', JSON.stringify(lastRecentSearch));

    var special_words = [{name:'插画',link:'/chahua-0-0-1.html'},{name:'海报',link:'/muban-67872-366-1.html'},{name:'展板',link:'/muban-246935-443-1.html'},{name:'展架',link:'/muban-251112-443-1.html'},{name:'易拉宝',link:'/muban-249980-443-1.html'},{name:'画册',link:'/muban-246287-444-1.html'},{name:'画册封面',link:'/muban-0-444-1-0-780-0-0-0-0.html'},{name:'名片',link:'/muban-0-406-1-0-407-0-0-0-0.html'},{name:'工作证',link:'/muban-0-406-1-0-779-0-0-0-0.html'},{name:'证书',link:'/muban-0-406-1-0-778-0-0-0-0.html'},{name:'优惠券',link:'/muban-0-406-1-0-408-0-0-0-0.html'},{name:'传单',link:'/tupian/muban-chuandan.html'},{name:'折页',link:'/tupian/muban-zheye.html'},{name:'二折页',link:'/tupian/muban-erzheye.html'},{name:'三折页',link:'/tupian/muban-sanzheye.html'},{name:'淘宝手机模板' ,link:'/mobile.html'},{name:'片头',link:'/media/video-piantou.html'},{name:'字幕',link:'/media/video-125753.html'},{name:'快闪',link:'/media/video-kuaishan.html'},{name:'视频片头',link:'/media/video-385290.html'},{name:'片尾',link:'/media/video-pianwei.html'},{name:'背景视频',link:'/media/video-beijingshipin.html'},{name:'粒子特效',link:'/media/video-lizitexiao.html'},{name:'转场',link:'/media/video-783738.html'},{name:'开场',link:'/media/video-372267.html'},{name:'会声会影',link:'/media/video-393550.html'},{name:'字幕条',link:'/media/video-zimutiao.html'},{name:'竞聘',link:'/office/ppt-337241.html'},{name:'pr',link:'/media/video-pr.html'},{name:'宣传片',link:'/media/video-xuanchuanpian.html'},{name:'结尾',link:'/media/video-jiewei.html'},{name:'新闻片头',link:'/media/video-xinwenpiantou.html'},{name:'婚礼片头',link:'/media/video-hunlipiantou.html'},{name:'开场视频',link:'/media/video-kaichangshipin.html'},{name:'mg',link:'/media/video-mg.html'},{name:'时间轴',link:'/media/video-shijianzhou.html'},{name:'启动仪式',link:'/media/video-qidongyishi.html'},{name:'企业宣传片',link:'/media/video-509074.html'},{name:'年会开场',link:'/media/video-nianhuikaichang.html'},{name:'文字快闪',link:'/media/video-wenzikuaishan.html'},{name:'绿幕',link:'/media/video-471477.html'},{name:'元素',link:'/tupian/sucai-so.html'},{name:'台历',link:'/tupian/muban-taili.html'},{name:'宣传单',link:'/tupian/muban-xuanchuandan.html'},{name:'彩页',link:'/chuandan.html'},{name:'节目单',link:'/tupian/muban-jiemudan.html'},{name:'贺卡',link:'/muban-0-406-1-0-865-0-0-0-0.html'},{name:'电商',link:'/tupian/muban-dianshang.html'},{name:'万圣节海报',link:'/tupian/muban-wanshengjie.html'},{name:'圣诞节海报',link:'/tupian/muban-shengdanjie.html'},{name:'新年海报',link:'/muban-143090-366-1.html'},{name:'猪年海报',link:'/muban-2428422-366-1.html'},{name:'春节海报',link:'/muban-179687-366-1.html'},{name:'vi样机',link:'/muban-0-788-1-0-804-0-0-0-0.html'},{name:'手机样机',link:'/muban-69271-788-1.html'},{name:'电子设备样机',link:'/muban-0-788-1-0-801-0-0-0-0.html'},{name:'包装样机',link:'/muban-0-788-1-0-810-0-0-0-0.html'},{name:'海报样机',link:'/muban-67872-788-1.html'},{name:'企业形象墙',link:'/muban-263858-0-1.html'},{name:'文化墙',link:'/tupian/muban-wenhuaqiang.html'},{name:'杂志排版',link:'/huace.html'},{name:'文化展板',link:'/tupian/muban-wenhuazhanban.html'},{name:'房地产广告',link:'/tupian/muban-fangdichan.html'},{name:'微商海报',link:'/muban-251041-366-1.html'},{name:'美容画册',link:'/muban-206606-444-1.html'},{name:'价目表',link:'/muban-143555-592-1.html'},{name:'ae片头模板',link:'/video-sousuo-303190-0-1-all-complex-0-0-0.html'},{name:'视频',link:'/video-sousuo-0-0-1-all-popular-0-0-0.html'},{name:'ae模板',link:'/video-sousuo-393891-2-1-all-popular-0-0-0.html'},{name:'相册模板',link:'/video-sousuo-303279-5-1-all-complex-0-0-0.html'},{name:'延时视频',link:'/video-sousuo-2816166-1-1-0-0-0.html'},{name:'电影片头',link:'/media/video-dianyingpiantou.html'},{name:'会声会影模板',link:'/video-sousuo-1966971-3-1-all-popular-0-0-0.html'},{name:'视频素材',link:'/video-sousuo-306707-0-1-all-popular-0-0-0.html'},{name:'婚礼视频',link:'/video-sousuo-392353-0-1-all-complex-0-0-0.html'},{name:'mg动画',link:'/media/video-622567.html'},{name:'会声会影x9',link:'/video-sousuo-6078543-3-1-all-new-0-0-0.html'},{name:'免费视频',link:'/media/video-mianfeishipin.html'},{name:'婚礼背景视频',link:'/media/video-hunlibeijing.html'},{name:'颁奖背景视频',link:'/media/video-banjiangbeijing.html'},{name:'logo演绎',link:'/media/video-logoyanyi.html'},{name:'ae片头',link:'/video-sousuo-312834-2-1-all-complex-0-0-0.html'},{name:'年会倒计时',link:'/video-sousuo-2027129-0-1-all-complex-0-0-0.html'},{name:'电影特效',link:'/media/video-dianyingtexiao.html'},{name:'婚庆片头',link:'/media/video-2251329.html'},{name:'年会视频',link:'/video-sousuo-1948821-0-1-all-complex-0-0-0.html'},{name:'片尾字幕',link:'/media/video-pianweizimu.html'},{name:'字幕模板',link:'/video-sousuo-3826783-0-1-all-popular-0-0-0.html'},{name:'震撼片头',link:'/video-sousuo-3045775-2-1-0-0-0.html'},{name:'电子相册',link:'/media/video-xiangce.html'},{name:'震撼',link:'/video-sousuo-248336-2-1-all-popular-0-0-0.html'},{name:'背景音乐',link:'/media/soundtrack-beijingyinyue.html'},{name:'轻音乐',link:'/media/soundtrack-qingyinyue.html'},{name:'纯音乐',link:'/media/soundtrack-491498.html'},{name:'婚礼配乐',link:'/media/soundtrack-hunli.html'},{name:'音效',link:'/soundeffect/'},{name:'生日ppt',link:'/office/ppt-shengri.html'},{name:'婚礼ppt',link:'/office/ppt-hunli.html'},{name:'快闪ppt',link:'/office/ppt-kuaishan.html'},{name:'相册ppt',link:'/office/ppt-xiangce.html'},{name:'小清新ppt',link:'/office/ppt-xiaoqingxin.html'},{name:'中国风ppt',link:'/office/ppt-zhongguofeng.html'},{name:'微立体ppt',link:'/office/ppt-734496.html'},{name:'简约ppt',link:'/muban-0-263-1-316-0-0-0-0-0.html'},{name:'党建ppt',link:'/office/ppt-dangjian.html'},{name:'企业ppt',link:'/office/ppt-qiye.html'},{name:'商务ppt',link:'/office/ppt-shangwu.html'},{name:'商业计划书ppt',link:'/office/ppt-shangyejihuashu.html'},{name:'企业宣传ppt',link:'/muban-0-263-1-0-307-0-0-0-0.html'},{name:'工作总结ppt',link:'/office/ppt-gongzuozongjie.html'},{name:'工作计划ppt',link:'/office/ppt-394663.html'},{name:'课件ppt',link:'/office/ppt-313580.html'},{name:'家长会ppt',link:'/office/ppt-jiazhanghui.html'},{name:'答辩ppt',link:'/office/ppt-325046.html'},{name:'2019ppt',link:'/muban-2130342-263-complex-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'新年ppt',link:'/office/ppt-xinnian.html'},{name:'年会ppt',link:'/office/ppt-nianhui.html'},{name:'年终总结',link:'/office/ppt-nianzhongzongjie.html'},{name:'颁奖ppt',link:'/office/ppt-banjiang.html'},{name:'摄影图',link:'/tupian/photo-so.html'},{name:'封面背景',link:'/chahua-0-337-1-365-0-0-0-0-0.html'},{name:'建筑插画',link:'/tupian/chahua-jianzhu.html'},{name:'促销海报',link:'/vector-0-366-popular-all-0-all-all-1-0-373-0-0-0-0-all-all.html'},{name:'节气海报',link:'/vector-260092-366-1.html'},{name:'节日海报',link:'/vector-150250-366-1.html'},{name:'地产海报',link:'/vector-0-366-1-0-374-0-0-0-0.html'},{name:'美食海报',link:'/vector-0-366-1-0-375-0-0-0-0.html'},{name:'教育海报',link:'/vector-0-366-1-0-376-0-0-0-0.html'},{name:'招聘海报',link:'/vector-0-366-1-0-377-0-0-0-0.html'},{name:'旅游海报',link:'/vector-0-366-1-0-379-0-0-0-0.html'},{name:'化妆品海报',link:'/vector-0-366-1-0-381-0-0-0-0.html'},{name:'中国风海报',link:'/vector-0-366-1-0-387-0-0-0-0.html'},{name:'健身海报',link:'/vector-175529-366-1.html'},{name:'运动海报',link:'/vector-102239-366-1.html'},{name:'汽车海报',link:'/vector-0-366-1-0-384-0-0-0-0.html'},{name:'公益海报',link:'/vector-0-366-1-0-383-0-0-0-0.html'},{name:'企业文化海报',link:'/vector-0-366-1-0-382-0-0-0-0.html'},{name:'党建海报',link:'/vector-0-366-1-0-378-0-0-0-0.html'},{name:'医疗海报',link:'/vector-72271-366-1.html'},{name:'美容海报',link:'/vector-206606-366-1.html'},{name:'美妆海报',link:'/vector-246068-366-1.html'},{name:'饮料海报',link:'/vector-132653-366-1.html'},{name:'风景海报',link:'/vector-218808-366-1.html'},{name:'中医海报',link:'/vector-130800-366-1.html'},{name:'秋冬上新',link:'/tupian/muban-qiudongshangxin.html'},{name:'册子',link:'/vector-4076108-444-1.html'},{name:'公司画册',link:'/vector-4076108-444-1.html'},{name:'折页设计',link:'/vector-254584-592-1.html'},{name:'dm单',link:'/chuandan.html'},{name:'dm单页',link:'/chuandan.html'},{name:'双十一页面',link:'/vector-246397-668-1.html'},{name:'双十一承接页',link:'/vector-246397-668-1.html'},{name:'封皮',link:'/vector-0-444-1-0-780-0-0-0-0.html'},{name:'公司背景墙',link:'/vector-266772-443-1.html'},{name:'ae模版',link:'/media/videoae.html'},{name:'绘声绘影',link:'/video-sousuo-1966971-3-1-all-popular-0-0-0.html'},{name:'pr模版',link:'/media/videopr.html'},{name:'ae片头模版',link:'/video-sousuo-303190-0-1-all-complex-0-0-0.html'},{name:'相册模版',link:'/video-sousuo-303279-5-1-all-complex-0-0-0.html'},{name:'会声会影模版',link:'/video-sousuo-1966971-3-1-all-popular-0-0-0.html'},{name:'字幕模版',link:'/video-sousuo-3826783-0-1-all-popular-0-0-0.html'},{name:'公司历程',link:'/media/video-shijianzhou.html'},{name:'启动',link:'/phoneMap-qidongye-1-0-0-0-0-complex-all-0-all-0-all-all.html'},{name:'启动页',link:'/phoneMap-qidongye-1-0-0-0-0-complex-all-0-all-0-all-all.html'},{name:'开屏页',link:'/phoneMap-kaipingye-1-0-0-0-0-complex-all-0-all-0-all-all.html'},{name:'引导页',link:'/phoneMap-kaipingye-1-0-0-0-0-complex-all-0-all-0-all-all.html'},{name:'专题',link:'/zhuanti.html'},{name:'新年视频',link:'/media/video-143090.html'},{name:'视频背景',link:'/media/videobjsp.html'},{name:'抽奖背景',link:'/media/video-choujiang.html'},{name:'动感背景',link:'/video-sousuo-247821-7-1-0-0-0.html'},{name:'图片展示',link:'/media/video-954790.html'},{name:'年会抽奖',link:'/media/video-choujiang.html'},{name:'产品宣传',link:'/media/video-chanpinxuanchuan.html'},{name:'倒数',link:'/video-all-0-0-1-all-complex-2-0.html'},{name:'LED屏幕',link:'/media/videobjsp.html'},{name:'春节视频',link:'/media/video-chunjie.html'},{name:'喜庆视频',link:'/media/video-xiqingshipin.html'},{name:'图片汇聚',link:'/media/video-tupianhuiju.html'},{name:'图片视频',link:'/media/video-tupianshipin.html'},{name:'word',link:'/office/word-so.html'},{name:'word模板',link:'/office/word-so.html'},{name:'word文档',link:'/office/word-so.html'},{name:'excel模板',link:'/excel/'},{name:'excel表格',link:'/excel/'},{name:'excel',link:'/excel/'},{name:'简历',link:'/office/word-jianli.html'},{name:'个人简历',link:'/office/word-jianli.html'},{name:'简历模板',link:'/office/word-jianli.html'},{name:'求职简历',link:'/office/word-jianli.html'},{name:'毕业答辩',link:'/office/ppt-biyedabian.html'},{name:'论文答辩',link:'/office/ppt-biyedabian.html'},{name:'毕业答辩ppt',link:'/office/ppt-biyedabian.html'},{name:'教育课件',link:'/office/ppt-jiaoyukejian.html'},{name:'教育课件ppt',link:'/office/ppt-jiaoyukejian.html'},{name:'海报设计',link:'/haibao.html'},{name:'商业海报',link:'/haibao.html'},{name:'淘宝海报',link:'/banners.html'},{name:'淘宝banner',link:'/banners.html'},{name:'淘宝主图',link:'/zhitongche.html'},{name:'主图',link:'/zhitongche.html'},{name:'主图背景',link:'/zhitongche.html'},{name:'淘宝首页',link:'/shouye.html'},{name:'店铺装修',link:'/shouye.html'},{name:'详情页',link:'/pages.html'},{name:'淘宝详情页',link:'/pages.html'},{name:'pr模板',link:'/media/videopr.html'},{name:'pr',link:'/media/videopr.html'},{name:'样机',link:'/yangjisucai.html'},{name:'样机素材',link:'/yangjisucai.html'},{name:'字体下载',link:'/sucai/zitiyuansu.html'},{name:'字体设计',link:'/sucai/zitiyuansu.html'},{name:'字体元素',link:'/sucai/zitiyuansu.html'},{name:'宣传单页',link:'/chuandan.html'},{name:'商业计划书',link:'/ppt-270961-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'工作总结',link:'/ppt-289282-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'工作计划',link:'/ppt-394663-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'工作汇报',link:'/ppt-328455-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'自我介绍',link:'/ppt-265100-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'职业规划',link:'/ppt-291689-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'述职报告',link:'/ppt-450375-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'招聘ppt',link:'/ppt-2492737-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'年度总结',link:'/ppt-336959-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'毕业论文',link:'/ppt-755819-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'岗位竞聘',link:'/ppt-1277582-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'个人述职',link:'/ppt-296177-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'个人总结',link:'/ppt-261155-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'幻灯片',link:'/ppt-0-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'计划书',link:'/ppt-0-263-yesterdaydl-all-0-all-all-1-0-306-0-0-0-0-all-all.html'},{name:'家长会',link:'/ppt-314547-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'开题报告',link:'/ppt-1879295-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'论文',link:'/ppt-607244-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'年度计划',link:'/ppt-293557-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'年终述职',link:'/ppt-296176-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'年终总结',link:'/ppt-264399-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'授课',link:'/ppt-0-263-yesterdaydl-all-0-all-all-1-0-309-0-0-0-0-all-all.html'},{name:'新年计划',link:'/ppt-370549-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'员工培训',link:'/ppt-175946-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'PowerPoint',link:'/ppt-287443-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'PPT年会',link:'/ppt-2328379-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'wpsPPT',link:'/ppt-0-263-yesterdaydl-all-0-all-all-1-0-309-0-0-0-0-all-all.html'},{name:'办公PPT',link:'/ppt-0-263-yesterdaydl-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'入职培训',link:'/ppt-1119297-263-yesterdaydl-all-0-all-all-1-0-309-0-0-0-0-all-all.html'},{name:'动态海报',link:'/gif/jieri.html'},{name:'gif',link:'/gif/'},{name:'动图',link:'/gif/'},{name:'gif动图',link:'/gif/'},{name:'gif动图素材',link:'/gif/'},{name:'动图素材',link:'/gif/'},{name:'gif素材',link:'/gif/'},{name:'动态配图',link:'/gif/'},{name:'表情包',link:'/gif/katong.html'},{name:'插画动图',link:'/gif/chahua.html'},{name:'插画gif',link:'/gif/chahua.html'},{name:'艺术字',link:'/tupian/sucai-yishuzi.html'},{name:'艺术字体',link:'/tupian/sucai-yishuzi.html'},{name:'漂浮素材',link:'/tupian/sucai-piaofusucai.html'},{name:'漂浮元素',link:'/tupian/sucai-piaofusucai.html'},{name:'效果素材',link:'/tupian/sucai-xiaoguosucai.html'},{name:'效果元素',link:'/tupian/sucai-xiaoguoyuansu.html'},{name:'促销标签',link:'/sucai-cuxiaobiaoqian-1-0-0-0-0-complex-all-0-all-0-all-all.html'},{name:'边框',link:'/tupian/sucai-biankuang.html'},{name:'装饰图案',link:'/sucai/biankuangdiwen.html'},{name:'光效',link:'/tupian/sucai-guangxiao.html'},{name:'卡通人物',link:'/tupian/sucai-katongrenwu.html'},{name:'小报',link:'/word/xiaobao.html'},{name:'手抄报',link:'/word/xiaobao.html'},{name:'答辩',link:'/office/ppt-325046.html'},{name:'信纸',link:'/word-249088-355-complex-all-0-all-all-1-0-0-0-0-0-0-all-all.html'},{name:'AE',link:'/media/videoae.html'},{name:'汇聚',link:'/media/video-huiju.html'},{name:'转场特效',link:'/video-sousuo-783738-260-1-0-0-0.html'},{name:'led背景',link:'/video-all-247924-0-1-all-popular-0-0.html'},{name:'文字特效',link:'/media/video-wenzitexiao.html'},{name:'ae素材',link:'/media/videoae.html'},{name:'倒计时10秒',link:'/media/video-daojishi10miao.html'},{name:'ae文字',link:'/media/video-aezimu.html'}];
    $.each(special_words, function(index, val) {
        if((word == val.name && searchMode == 'all') || (word == val.name && isSearchPage == 4)) {
            isSpecialWords = true
            location.href = '//699pic.com'+val.link;
            return false
        }
    });
    if(isSpecialWords) {
        return
    }
    var searchUrl = devAjaxPrefix + "/search/getKwInfo";
    $.get(searchUrl, {'kw': word}, function(rep){
        if (searchMode == 'photo') {
            location.href = "//699pic.com/tupian/photo-" + rep.pinyin + ".html";
        } else if (searchMode == 'chahua') {
            location.href = "//699pic.com/tupian/chahua-" + rep.pinyin + ".html";
        } else if (searchMode == 'muban') {
            location.href = "//699pic.com/tupian/muban-" + rep.pinyin + ".html ";
        } else if (searchMode == 'video') {
             location.href = "//699pic.com/video-sousuo-" + rep.kwid + "-0-1.html";
        } else if (searchMode == 'originality') {
            location.href = "//699pic.com/tupian/chuangyi-" + rep.pinyin + ".html ";
        } else if (searchMode == 'PPT') {
             location.href = "//699pic.com/office/ppt-" + rep.pinyin + ".html ";
        } else if (searchMode == 'word') {
            location.href = "//699pic.com/office/word-" + rep.pinyin + ".html ";
        } else if (searchMode == 'excel') {
            location.href = "//699pic.com/office/excel-" + rep.pinyin + ".html ";
        } else if (searchMode == 'peitu') {
            location.href = "//699pic.com/tupian/peitu-" + rep.pinyin +".html";
        } else if (searchMode == 'yuansu') {
            location.href = "//699pic.com/tupian/sucai-" + rep.pinyin + ".html";
        } else if (searchMode == 'gif') {
            location.href = "//699pic.com/tupian/gif-" + rep.pinyin + ".html";
        } else if (searchMode == 'soundeffect') {
            location.href = "//699pic.com/media/soundeffect-" + rep.pinyin + ".html";
        } else if (searchMode == 'soundtrack') {
            location.href = "//699pic.com/media/soundtrack-" + rep.pinyin + ".html";
        } else if (searchMode == 'ziti') {
            location.href = "//699pic.com/font/";
        } else if (searchMode == 'gif') {
            location.href = "//699pic.com/tupian/gif-" + rep.pinyin + ".html";
        } else if (searchMode == 'music') {
            location.href = "//699pic.com/music/kw-" + rep.pinyin + ".html";
        } else {
            location.href = "//699pic.com/tupian/" + rep.pinyin + ".html";
        }
    });
}


function sendRecommend(type , uniqid) {

	$.ajax({
        url: '//ajax.699pic.com/index.php?c=ajaxPublic&a=recommend',
        type: 'post',
        dataType: 'json',
        data: {
            type: type,
            uniqid: uniqid
        },
        success: function (data) {
            if(data.status == 1) {
                callback && callback(data.data);
            }
        },
        error: function (error) {
            console.log(error);
        }
    })
}
$('.header-search .header-search_tag').hover(function() {
    $('.search-hint').fadeOut();
}, function() {
    $('.search-hint').fadeOut();
});
$("#photo_search").submit(function () {
    if(window.FormData) {
        var data = new window.FormData($("#photo_search")[0]);
    } else {
        return ;
    }
    $.ajax({
        url: 'http://v0.api.upyun.com/sheyingtu-web-95',
        type: 'POST',
        data: data,
        cache: false,
        processData: false,
        contentType: false,
    }).done(function(data, textStatus) {
        var data = JSON.parse(data);
        window.location.href = '/shitu/search?url='+data['url'];
    }).fail(function(res, textStatus, error) {
        var data = JSON.parse(res['responseText']);
        if (data && data['code'] == '403') {
            if (data['message'].indexOf('small') > -1) {
                $(".error-hint-clue").html('您上传的图片过小');
            } else if (data['message'].indexOf('large') > -1) {
                $(".error-hint-clue").html('您上传的图片过大');
            } else if (data['message'].indexOf('type error') > -1) {
                $(".error-hint-clue").html('您上传的图片类型不正确');
            }
        }
        $(".put-img-hint").show();
        $(".uploading").hide();
        $(".error-hint").show();
        // 统计上传失败次数
        shitu({upload:2});
    });
    return false;
});
// 首页以图搜图统计 type = 1 为首页 ，type = 2为列表页
function shitu (data) {
    var url = "http://ajax.699pic.com/?c=Ajax&a=shitu";
    $.ajax({
        type: "get",
        url: url,
        jsonp: "",
        data:data,
        dataType: "jsonp",
        success: function (data) {}
    });
}

// 下载 弹窗提示
var loadedAlert = {};
function doAlert(path,data){
    console.log(loadedAlert[path]);
    if( loadedAlert[path] ){
        eval(loadedAlert[path].run)
        return;
    }
    $.post(path,data,function( response ){
        if( response.state ){
            loadedAlert[path] = response;
            $(response.doc).appendTo('body');
            eval(response.run);
        }else{

        }
    })
}
window.env.doAlert = doAlert;

function doAlertNoCache(path,data){
    $.post(path,data,function( response ){
        if( response.state ){
            $(document).find('.faceCen,.alert-bg').remove();
            $(response.doc).appendTo('body');
            eval(response.run);
        }else{
        }
    })
}
window.env.doAlertNoCache = doAlertNoCache;